<?php
class Shop_Model_TenpoOemJump extends Shop_Model_Base{

    /**
     * 
     * @param unknown_type $params
     */
    public function getPrefCdList($params)
    {
        $db_params = array();

        $dbList = array();
        $PrefCdList = array();
        $strOemCd = (string)$params['OemCd'];
        $strOemType = (string)$params['OemType'];
        $strOemTgt = '';
        
        switch ($strOemType)
        {
            case Apm_Config_Shop::OEM_TYPE_HOJIN :
                $strOemTgt = 'M05_HOUZIN_CD';
                break;
            case Apm_Config_Shop::OEM_TYPE_TENPO :
                $strOemTgt = 'M05_TENPO_CD';
                break;
        }

$sql = <<< docEnd
            SELECT
                T03_TODOUFUKEN_CD AS TODOUFUKEN_CD
            FROM
                T03WEB_HEYA,
                M05TENPO_INFO
            WHERE
                {$strOemTgt} = '{$strOemCd}'
                AND M05_TENPO_CD = T03_TENPO_CD
            GROUP BY
                T03_TODOUFUKEN_CD
docEnd;

        $dbList = $this->dbGetList($sql, $db_params);
        
        // データが取得できなかった場合
        if (count($dbList) <= 0)
        {
$sql = <<< docEnd
            SELECT
                DISTINCT M05_TENPO_TODOUFUKEN_CD AS TODOUFUKEN_CD
            FROM
                M05TENPO_INFO
            WHERE
                {$strOemTgt} = '{$strOemCd}'
docEnd;

            $dbList = $this->dbGetList($sql, $db_params);
        }
        
        foreach ($dbList as $dbData)
        {
        	$PrefCdList[] = (string)$dbData['TODOUFUKEN_CD'];
        }
                
        return $PrefCdList;
    }
}
?>
